//
//  UIView+ex.swift
//  WZApp
//
//  Created by evol on 2018/7/26.
//  Copyright © 2018年 evol. All rights reserved.
//

import UIKit

extension UIView {
    var left: CGFloat {
        get {
            return self.frame.minX
        }
        set {
            var frame = self.frame
            frame.origin.x = newValue
            self.frame = frame
        }
    }
    
    var top: CGFloat {
        get {
            return self.frame.minY
        }
        set {
            var frame = self.frame
            frame.origin.y = newValue
            self.frame = frame
        }
    }
    
    var width: CGFloat {
        get {
            return self.frame.width
        }
        
        set {
            var frame = self.frame
            frame.size.width = newValue
            self.frame = frame
        }
    }
    
    var height: CGFloat {
        get {
            return self.frame.height
        }
        
        set {
            var frame = self.frame
            frame.size.height = newValue
            self.frame = frame
        }
    }
    
    var centerX: CGFloat {
        get {
            return self.frame.midX
        }
        set {
            var frame = self.frame
            frame.origin.x = newValue - frame.width/2
            self.frame = frame
        }
    }
    
    var centerY: CGFloat {
        get {
            return self.frame.midY
        }
        set {
            var frame = self.frame
            frame.origin.y = newValue - frame.height/2
            self.frame = frame
        }
    }
}
